<?php

/**
 * Recipient filter form base class.
 *
 * @package    25Mails
 * @subpackage filter
 * @author     fabio.lorenzini@25solutions.com
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseRecipientFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'username'          => new sfWidgetFormFilterInput(),
      'email'             => new sfWidgetFormFilterInput(),
      'private'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'name'              => new sfWidgetFormFilterInput(),
      'surname'           => new sfWidgetFormFilterInput(),
      'businessname'      => new sfWidgetFormFilterInput(),
      'country'           => new sfWidgetFormFilterInput(),
      'language'          => new sfWidgetFormFilterInput(),
      'subscription'      => new sfWidgetFormFilterInput(),
      'discount_percent'  => new sfWidgetFormFilterInput(),
      'free_since'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'pro_since'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'pro_end'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'past_subscription' => new sfWidgetFormFilterInput(),
      'newsletter'        => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'active'            => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'username'          => new sfValidatorPass(array('required' => false)),
      'email'             => new sfValidatorPass(array('required' => false)),
      'private'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'name'              => new sfValidatorPass(array('required' => false)),
      'surname'           => new sfValidatorPass(array('required' => false)),
      'businessname'      => new sfValidatorPass(array('required' => false)),
      'country'           => new sfValidatorPass(array('required' => false)),
      'language'          => new sfValidatorPass(array('required' => false)),
      'subscription'      => new sfValidatorPass(array('required' => false)),
      'discount_percent'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'free_since'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'pro_since'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'pro_end'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'past_subscription' => new sfValidatorPass(array('required' => false)),
      'newsletter'        => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'active'            => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('recipient_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Recipient';
  }

  public function getFields()
  {
    return array(
      'recipient_id'      => 'Number',
      'username'          => 'Text',
      'email'             => 'Text',
      'private'           => 'Boolean',
      'name'              => 'Text',
      'surname'           => 'Text',
      'businessname'      => 'Text',
      'country'           => 'Text',
      'language'          => 'Text',
      'subscription'      => 'Text',
      'discount_percent'  => 'Number',
      'free_since'        => 'Date',
      'pro_since'         => 'Date',
      'pro_end'           => 'Date',
      'past_subscription' => 'Text',
      'newsletter'        => 'Boolean',
      'active'            => 'Boolean',
    );
  }
}
